$(function () {
	vm.searchCheckList();
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		storeMaterialCheck: {},
        storeMaterialCheckList:[],
        storeMaterialCheckDetailVoList:[],
		query:{

		},
		page:{
            size:10,
            totalCount:null,
            pageCount:null,
            currentPage:1
		},
        e:{
		    checkStatus:[
                {label:'待审核',value:1},
                {label:'审核通过',value:2},
                {label:'驳回',value:3}
            ]
        }

	},
	methods: {
		searchCheckList:function(){
			debugger;
			var self = this;
            self.query.limit = self.page.size;
            self.query.page = self.page.currentPage;
			$.ajax({
                type: "POST",
                url: baseURL + "storeMaterialCheck/storematerialcheck/list",
                contentType: "application/json",
                data: JSON.stringify(self.query),
                success: function(r){
                	debugger;
                    if(r.code === 0){
						self.storeMaterialCheckList = r.page.list;
						self.page.pageCount = r.page.totalPage;
                        self.page.totalCount = r.page.totalCount;
                        self.page.currentPage = r.page.currPage;
                    }else{
                        alert(r.msg);
                    }
                }
			})
		},
        currentChange:function(current){
			debugger;
            this.page.currentPage = current;
            console.info(this.page.currentPage);
			this.searchCheckList();
		},
        sizeChange:function(size){
            this.page.size = size;
            console.info(this.page.size);
            this.searchCheckList();
		},

        view:function(index){
			this.storeMaterialCheck = this.storeMaterialCheckList[index];
			var self = this;
            $.get(baseURL + "storeMaterialCheck/storematerialcheck/checkInfo/"+self.storeMaterialCheck.checkId, function(r){
                self.showList = false;
                self.storeMaterialCheckDetailVoList = r.storeMaterialCheckDetailVoList;
            });
		},
		audit:function(){
		    var materialCheckVo = {};
            materialCheckVo.storeMaterialCheck = this.storeMaterialCheck;
            materialCheckVo.storeMaterialCheckDetailVoList = this.storeMaterialCheckDetailVoList;
		    //提交审核信息
            // var self = this;
            $.ajax({
                type: "POST",
                url: baseURL + "storeMaterialCheck/storematerialcheck/auditCheck",
                contentType: "application/json",
                data: JSON.stringify(materialCheckVo),
                success: function(r){
                    debugger;
                    if(r.code === 0){
                        console.info("success")
                    }else{
                        alert(r.msg);
                    }
                }
            })


		},
        goBack:function(){
            this.showList = true;
            this.storeMaterialCheck = {};
		},
        // auditAjax:function(mark,checkId){
		 //    debugger;
        //     $.ajax({
        //         type: "POST",
        //         url: baseURL + "storeMaterialCheck/storematerialcheck/auditCheck/"+mark+"/"+checkId,
        //         contentType: "application/json",
        //         success: function(r){
        //             debugger;
        //             if(r.code === 0){
        //                 console.info("success")
        //             }else{
        //                 alert(r.msg);
        //             }
        //         }
        //     })
        // }

	}
});